package www.openteam.com.presenter.business;

import java.util.HashMap;
import java.util.function.Consumer;

import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func0;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.Evaluate_customer;
import www.openteam.com.contract.realtime.EvaluateContract;
import www.openteam.com.model.realtime.EvaluateModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.realtime.EvaluateFragment;

public class EvaluatePresenter extends BasePresenter<EvaluateFragment> implements EvaluateContract.EvaluatePresenter {

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new EvaluateModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("EvaluatePresenter", models[0]);
        return hashMap;
    }

    @Override
    public void findCustomerCode() {
        ((EvaluateModel) getiModelMap().get("EvaluatePresenter")).findEvaCustomer()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(new Action1<Evaluate_customer>() {
//                    @Override
//                    public void call(Evaluate_customer evaluate_customer) {
//
//                    }
//                });
                .subscribe(data -> {
                    getIView().findCustomerCodeSucess(data);
                });
    }

    @Override
    public void findPbMonerytype() {
        ((EvaluateModel) getiModelMap().get("EvaluatePresenter")).finPbMonerytype()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(data -> getIView().findPbMoneryType(data));
    }

    @Override
    public void findProductMsg(String stype, int userId) {
        ((EvaluateModel) getiModelMap().get("EvaluatePresenter")).findProductMsg(stype, userId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(data -> getIView().findProductMsg(data));
    }

    @Override
    public void findPbMaterial() {
        ((EvaluateModel) getiModelMap().get("EvaluatePresenter")).findPbMaterial()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(data->getIView().findPbMaterial(data));
    }

    @Override
    public void findPbKzMsg() {
        ((EvaluateModel) getiModelMap().get("EvaluatePresenter")).findPbKzMsg()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(data->getIView().findPbKzMsg(data));
    }
}
